home *** CD-ROM | disk | FTP | other *** search
- Path: news.umbc.edu!not-for-mail
- From: schlein@umbc.edu (Jonas J. Schlein)
- Newsgroups: comp.lang.c
- Subject: Re: command line argument help
- Date: 27 Jan 1996 15:57:32 -0500
- Organization: University of Maryland Baltimore County
- Message-ID: <4ee3js$h57@umbc9.umbc.edu>
- References: <4edfth$ok@muss.CIS.McMaster.CA>
- NNTP-Posting-Host: umbc9.umbc.edu
- NNTP-Posting-User: schlein
-
- In article <4edfth$ok@muss.CIS.McMaster.CA>, <shadowfax> wrote:
- |> to all the c gods out there:
-
- I don't see any, but I'll try to help anyway...
-
- |> i am not having too much success with command line arguments. i am
- |> trying to make a simple sumation executable for dos. i am using borland
- |> c++ v3.1. what i want as the end result is the user just types:
- |>
- |> c:\> sum 6 3
- |>
- |> and the executable would output an answer of 9. the following is my program:
- |>
- |> #include <stdio.h>
- |> #include <stdlib.h>
- |>
- |> int main(char *argv[])
-
- Well there ya go! This is an illegal definition of main(). Instead use
- int main (int argc, char *argv[]).
-
- |> {
- |> int iSum = 0;
- |>
- |> iSum = atoi(argv[1]) + atoi(argv[2]);
- |> printf("\nthe answer is %d", iSum);
-
- You may want to end the printf() with a '\n' as well.
-
- |> return(0);
-
- Good going...You get bonus points!
-
- |> }
- |>
- |> when i compile and run, it always outputs an anser of 0. can anyone tell
- |> me what's wrong?
-
- Already did...Make the change to the definition of main() and you'll be good
- to go!
- --
- "If it wasn't for C, we would be using BASI, PASAL, and OBOL."
-
- Jonas J. Schlein (schlein@gl.umbc.edu)
-